<?php
	class SQL{
		private $db;
		private $rows;
		private $nbRows;

		function Query($query,$bind=null){
			$this->db = eden(Config::$type,Config::$host,Config::$dbas,Config::$user,Config::$pass);
			//$this->connectDB();
			//debug Query
			if(Config::$debugQuery)
				$this->debugQuery($query);

			if(!isset($bind)){				
				$this->rows = $this->db->query($query);
			}else{
				$this->rows = $this->db->query($query,$bind);
			}
			//Debug des données
			if(Config::$debugRows)
				$this->debugRows();

			$this->nbRows = count($this->rows);

			return $this->rows;
		}

		function debugRows(){
			eden("debug")->output("<pre>".$this->nbRows."</pre>");
			eden("debug")->output("<pre>".print_r($this->rows)."</pre>");
			
		}

		function debugQuery($query){
			eden("debug")->output("Requete: ".$query);
			eden("debug")->output("<pre>".$this->nbRows."</pre>");
		}

		function getRows(){
			return $this->nbRows;
		}

	}
?>